package com.routing;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RoutingCustomers {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//不指定名字表示：创建临时队列
                    exchange = @Exchange(value = "directs",type ="direct" ),//绑定交换机
                    key = {"info","error","warning"}
            )
    })
    public void customer1(String message){
        System.out.println("Routing消费者1："+message);
    }
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//不指定名字表示：创建临时队列
                    exchange = @Exchange(value = "directs",type ="direct" ),//绑定交换机
                    key = {"warning"}
            )
    })
    public void customer2(String message){
        System.out.println("Routing消费者2："+message);
    }
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//不指定名字表示：创建临时队列
                    exchange = @Exchange(value = "directs",type ="direct" ),//绑定交换机
                    key = {"error"}
            )
    })
    public void customer3(String message){
        System.out.println("Routing消费者3："+message);
    }
}
